// onAMapLoaded = require('https://webapi.amap.com/maps?v=1.4.12&key=4030fc33588ec534428f38c3893ba07e&callback=onAMapLoaded')
export function MapLoaded(key) {
    let script = document.createElement('script')
    script.type = 'text/javascript'
    script.src = `//webapi.amap.com/maps?v=1.4.6&key=${key}&callback=init`
    script.async = true
    script.defer = true
    const LoadingPromise = new Promise((resolve, reject) => {
        window.init = () => {
            return resolve(window.AMap)
        }
        script.onerror = error => reject(error)
    })
    document.head.appendChild(script)
    return LoadingPromise
}